.class public Ldbclass/NotesService;
.super Ljava/lang/Object;
.source "NotesService.java"


# instance fields
.field DBOpenHelper:Ldbclass/DBOpenHelper;


# direct methods
.method public constructor <init>(Landroid/content/Context;)V
    .locals 1
    .param p1, "context"    # Landroid/content/Context;

    .prologue
    .line 21
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 22
    new-instance v0, Ldbclass/DBOpenHelper;

    invoke-direct {v0, p1}, Ldbclass/DBOpenHelper;-><init>(Landroid/content/Context;)V

    iput-object v0, p0, Ldbclass/NotesService;->DBOpenHelper:Ldbclass/DBOpenHelper;

    .line 23
    return-void
.end method


# virtual methods
.method public addNote(Lbean/NotesBean;)V
    .locals 5
    .param p1, "notesBean"    # Lbean/NotesBean;

    .prologue
    .line 30
    iget-object v1, p0, Ldbclass/NotesService;->DBOpenHelper:Ldbclass/DBOpenHelper;

    invoke-virtual {v1}, Ldbclass/DBOpenHelper;->getWritableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    .line 31
    .local v0, "db":Landroid/database/sqlite/SQLiteDatabase;
    const-string v1, "insert into notes(content) values(?)"

    const/4 v2, 0x1

    new-array v2, v2, [Ljava/lang/Object;

    const/4 v3, 0x0

    invoke-virtual {p1}, Lbean/NotesBean;->getConcet()Ljava/lang/String;

    move-result-object v4

    aput-object v4, v2, v3

    invoke-virtual {v0, v1, v2}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;[Ljava/lang/Object;)V

    .line 32
    return-void
.end method

.method public delete()V
    .locals 2

    .prologue
    .line 35
    iget-object v1, p0, Ldbclass/NotesService;->DBOpenHelper:Ldbclass/DBOpenHelper;

    invoke-virtual {v1}, Ldbclass/DBOpenHelper;->getWritableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    .line 36
    .local v0, "db":Landroid/database/sqlite/SQLiteDatabase;
    const-string v1, "delete from notes"

    invoke-virtual {v0, v1}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;)V

    .line 37
    return-void
.end method

.method public getAllNoteList()Ljava/util/List;
    .locals 8
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "()",
            "Ljava/util/List",
            "<",
            "Lbean/NotesBean;",
            ">;"
        }
    .end annotation

    .prologue
    .line 46
    new-instance v4, Ljava/util/ArrayList;

    invoke-direct {v4}, Ljava/util/ArrayList;-><init>()V

    .line 47
    .local v4, "list":Ljava/util/List;, "Ljava/util/List<Lbean/NotesBean;>;"
    iget-object v6, p0, Ldbclass/NotesService;->DBOpenHelper:Ldbclass/DBOpenHelper;

    invoke-virtual {v6}, Ldbclass/DBOpenHelper;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v2

    .line 48
    .local v2, "db":Landroid/database/sqlite/SQLiteDatabase;
    const-string v6, "select * from notes"

    const/4 v7, 0x0

    invoke-virtual {v2, v6, v7}, Landroid/database/sqlite/SQLiteDatabase;->rawQuery(Ljava/lang/String;[Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v1

    .line 49
    .local v1, "cursor":Landroid/database/Cursor;
    :goto_0
    invoke-interface {v1}, Landroid/database/Cursor;->moveToNext()Z

    move-result v6

    if-nez v6, :cond_0

    .line 57
    invoke-interface {v1}, Landroid/database/Cursor;->close()V

    .line 58
    return-object v4

    .line 50
    :cond_0
    const-string v6, "_id"

    invoke-interface {v1, v6}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I

    move-result v6

    invoke-interface {v1, v6}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v3

    .line 51
    .local v3, "id":Ljava/lang/String;
    const-string v6, "content"

    invoke-interface {v1, v6}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I

    move-result v6

    invoke-interface {v1, v6}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v0

    .line 52
    .local v0, "content":Ljava/lang/String;
    new-instance v5, Lbean/NotesBean;

    invoke-direct {v5}, Lbean/NotesBean;-><init>()V

    .line 53
    .local v5, "notesBean":Lbean/NotesBean;
    invoke-virtual {v5, v3}, Lbean/NotesBean;->setId(Ljava/lang/String;)V

    .line 54
    invoke-virtual {v5, v0}, Lbean/NotesBean;->setConcet(Ljava/lang/String;)V

    .line 55
    invoke-interface {v4, v5}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    goto :goto_0
.end method
